package com.vitabuybuy.tv.network

import com.library.common.net.NetUrl
import com.vitabuybuy.tv.dto.AfterSaleDetailDto
import com.vitabuybuy.tv.dto.AfterSaleListDto
import com.vitabuybuy.tv.dto.FirstCategoryDto
import com.vitabuybuy.tv.dto.NegotiationDto
import rxhttp.IAwait
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse

/**
 * 作者：SimGa
 * 日期：2020/12/3
 * 时间：17:04
 * 包名：com.vitabuybuy.tv.network
 */
object AfterSaleRepository {

    fun applyAfterSale(params: HashMap<String, Any>): IAwait<String> {
        return RxHttp.postJson(NetUrl.api_apply_after_sale)
            .add("issue", params)
            .toResponse()
    }

    fun modifyAfterSale(params: HashMap<String, Any>): IAwait<String> {
        return RxHttp.postJson(NetUrl.api_apply_after_update)
            .add("issue", params)
            .toResponse()

    }

    fun getAfterSaleOrderList(
        pageNumber: Int
    ): IAwait<MutableList<AfterSaleListDto>> {
        return RxHttp.postJson(NetUrl.api_apply_after_sale_list)
            .add(
                "pageable", mapOf(
                    Pair("page", pageNumber),
                    Pair("size", 10),
                    Pair("desc", "id")
                )
            )
            .toResponse()
    }


    fun getAfterSaleDetail(
        id: Int?
    ): IAwait<AfterSaleDetailDto> {
        return RxHttp.postJson(
            NetUrl.api_apply_after_sale_detail
        ).add("id", id).toResponse()
    }


    fun haveSend(
        id: Int?,
        logisticsName: String,
        logisticsNumber: String,
        returnDescription: String
    ): IAwait<String> {
        return RxHttp.postJson(
            NetUrl.api_goods_have_sent
        )
            .add("id", id)
            .add("logisticsName", logisticsName)
            .add("logisticsNumber", logisticsNumber)
            .add("returnDescription", returnDescription)
            .toResponse()
    }


    fun withdrawTheApplication(
        id: Int?
    ): IAwait<String> {
        return RxHttp.postJson(
            NetUrl.api_withdraw_the_application
        ).add("id", id).toResponse()
    }

    fun getLogisticsCompany(): IAwait<MutableList<FirstCategoryDto>> {
        return RxHttp.postJson(
            NetUrl.api_get_all_wuliu_company
        ).addAll("{}").toResponse()
    }

    fun getNegotiationList(id: Int?): IAwait<MutableList<NegotiationDto>> {
        return RxHttp.postJson(NetUrl.api_xieshang_lishi)
            .add("issue", mapOf(Pair("id", id))).toResponse()
    }
}